let utils = data["utils"];
let STUtil = data["STUtil"];
let Node = data["Node"];
let SplayTree = data["SplayTree"];
let isInBbox = data["isInBbox"];
let getBboxOverlap = data["getBboxOverlap"];
let cmp = data["cmp"];
let crossProduct = data["crossProduct"];
let dotProduct = data["dotProduct"];
let compareVectorAngles = data["compareVectorAngles"];
let sineOfAngle = data["sineOfAngle"];
let cosineOfAngle = data["cosineOfAngle"];
let closestPoint = data["closestPoint"];
let horizontalIntersection = data["horizontalIntersection"];
let verticalIntersection = data["verticalIntersection"];
let intersection = data["intersection"];
let perpendicular = data["perpendicular"];
let rounder = data["rounder"];
let geomIn = data["geomIn"];

let geomOut = data["geomOut"];
// let RingOut = geomOut["RingOut"];
let Segment = data["Segment"];
let SweepEvent = data["SweepEvent"];

console.log("10PolygonClipping_geom-out03");


function PolyOut(exteriorRing) {
  this.exteriorRing = exteriorRing
  exteriorRing.poly = this
  this.interiorRings = []

  this.addInterior = function (ring) {
    this.interiorRings.push(ring)
    ring.poly = this
  }

  this.getGeom = function () {
    const geom = [this.exteriorRing.getGeom()]
    // exterior ring was all (within rounding error of angle calc) colinear points
    if (geom[0] === null) return null
    for (let i = 0, iMax = this.interiorRings.length; i < iMax; i++) {
      const ringGeom = this.interiorRings[i].getGeom()
      // interior ring was all (within rounding error of angle calc) colinear points
      if (ringGeom === null) continue
      geom.push(ringGeom)
    }
    return geom
  }
}

function MultiPolyOut(rings) {

  this.getGeom = function () {
    const geom = []
    for (let i = 0, iMax = this.polys.length; i < iMax; i++) {
      const polyGeom = this.polys[i].getGeom()
      // exterior ring was all (within rounding error of angle calc) colinear points
      if (polyGeom === null) continue
      geom.push(polyGeom)
    }
    return geom
  }

  this._composePolys = function (rings) {
    const polys = []
    for (let i = 0, iMax = rings.length; i < iMax; i++) {
      const ring = rings[i]
      if (ring.poly) continue
      if (ring.isExteriorRing()) polys.push(new PolyOut(ring))
      else {
        const enclosingRing = ring.enclosingRing()
        if (!enclosingRing.poly) polys.push(new PolyOut(enclosingRing))
        enclosingRing.poly.addInterior(ring)
      }
    }
    return polys
  }
  this.rings = rings
  this.polys = this._composePolys(rings)

}
geomOut["PolyOut"] = PolyOut;
geomOut["MultiPolyOut"] = MultiPolyOut;


return {
  "utils": utils,
  "STUtil": STUtil,
  "Node": Node,
  "SplayTree": SplayTree,
  "isInBbox": isInBbox,
  "getBboxOverlap": getBboxOverlap,
  "cmp": cmp,
  "crossProduct": crossProduct,
  "dotProduct": dotProduct,
  "compareVectorAngles": compareVectorAngles,
  // "length":length,
  "sineOfAngle": sineOfAngle,
  "cosineOfAngle": cosineOfAngle,
  "closestPoint": closestPoint,
  "horizontalIntersection": horizontalIntersection,
  "verticalIntersection": verticalIntersection,
  "intersection": intersection,
  "perpendicular": perpendicular,
  "rounder": rounder,
  "geomIn": geomIn,
  "geomOut": geomOut,
  "Segment": Segment,
  "SweepEvent": SweepEvent
}